package com.sysmenu.service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.pojo.NewsPojo;
import com.sysmenu.dao.NewDao;

public class NewsServiceImpl implements NewsService {
	private NewDao newDao;

	public NewDao getNewDao() {
		return newDao;
	}

	public void setNewDao(NewDao newDao) {
		this.newDao = newDao;
	}

	public boolean saveNews(NewsPojo newPojo) {
		int i = newDao.saveNews(newPojo);
		if (i == 0)
			return false;
		return true;
	}
	
	public List<NewsPojo> searchNewsList(Map<String, Object> paraMap)
	{
		List<NewsPojo> resultList = new ArrayList<NewsPojo>();
		List<NewsPojo> list =  newDao.searchNewsList(paraMap);
		SimpleDateFormat  format = new SimpleDateFormat("yyyy-MM-dd");
		for(NewsPojo pojo : list )
		{
			pojo.setCreateTimeStr(format.format(pojo.getCreateTime()));
			resultList.add(pojo);
		}
		return  resultList;
		
	}

	public int searchNewsCount(Map<String, Object> paraMap) {
	  return  newDao.searchNewsCount(paraMap);
	}
}
